package cn.edu.lzu.dao;

import cn.edu.lzu.entity.LabExamineClause;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @PackageName: cn.edu.lzu.dao
 * @InterfaceName: LabExamineClauseMapper
 * @Description: TODO
 * @Author: 张琦[QQ:3098086691]
 * @Date: 2020/3/21 16:28
 * @Version: 1.0
 */
@Mapper
public interface LabExamineClauseMapper {
    @Select("select * from lab_examine_clause where unit_id=#{unitId} and is_deleted=0 and examine_item_id=#{examineItemId} order by numerical_order ASC")
    List<LabExamineClause> selByUnitId(long unitId, int examineItemId);

    @Select("select count(*) from lab_examine_clause where unit_id=#{unitId} and is_deleted=0")
    int selTrueClauseCount(long unitId);

    @Insert("insert into lab_examine_clause (id, numerical_order, code_name, clause_name, reference_value, units, examine_item_id, unit_id, is_deleted) values (default, #{numericalOrder}, #{codeName}, #{clauseName}, #{referenceValue}, #{units}, #{examineItemId}, #{unitId}, 0)")
    int insLabExamineClause(LabExamineClause labExamineClause);

    @Update("update lab_examine_clause set is_deleted=1 where id=#{id}")
    int updDeleteClauseById(int id);

    @Select("select * from lab_examine_clause where is_deleted=0 and unit_id=#{unitId} and clause_name like concat('%', #{clauseName}, '%') order by numerical_order ASC")
    List<LabExamineClause> selFuzzyByLabClauseName(long unitId, String clauseName);

    @Select("select * from lab_examine_clause where is_deleted=0 and unit_id=#{unitId} and code_name like concat('%', #{codeName}, '%') order by numerical_order ASC")
    List<LabExamineClause> selFuzzyByLabClauseCodeName(long unitId, String codeName);

    @Select("select * from lab_examine_clause where is_deleted=0 and unit_id=#{unitId} and examine_item_id in( #{examineItemIds}) order by numerical_order ASC")
    List<LabExamineClause> selFuzzyByLabClauseExamineItemId(long unitId, String examineItemIds);

}
